﻿namespace Homework03
{
    internal class Program
    {
        /// <summary>
        ///To convert a decimal number to its binary number representation
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //input the decimal number
            Console.WriteLine("请输入一个十进制的数：");
            string? userInput = Console.ReadLine();

            //convert the string to int
            if (int.TryParse(userInput, out int decimalNumber))
            {
                // convert the decimal number into binary number
                string binaryNumber = Convert.ToString(decimalNumber, 2);

                // output the result
                Console.WriteLine("该整数的二进制形式是: "+ binaryNumber);
            }
            else
            {
                Console.WriteLine("输入的不是一个有效的整数。");
            }
        }
    }
}
